package Cars;

import Cars.Controllers.BaseController;
import Cars.Controllers.BusController;
import Cars.Controllers.CarController;
import Cars.Models.Bus;
import Cars.Models.Car;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object userInput;
        do {
            System.out.println("请输入你要选择的车类型 0 轿车 1 货车");
            userInput = BaseController.CreateObject(new Scanner(System.in).nextInt());
            System.out.println(userInput);
        }while(userInput==null);

        if (userInput instanceof Car) {
            do {
                System.out.println("请输入类型 1 别克商务舱GL8 2 宝马550i 3 别克林荫大道");
                try {
                    CarController.CreateCarType((Car) userInput,new Scanner(System.in).nextInt());
                    break;
                } catch (Exception e) {
                    System.out.println("Choice.CreateType Error");
                }
            }while (true);
            System.out.println("请输入租赁天数");
            System.out.println("应付钱数为"+((Car) userInput).CalcRent(new Scanner(System.in).nextShort()));
        }else{
            do {
                System.out.println("分别 输入类型 1 金杯 2 金龙 和类型座位数目");
                try {
                    BusController.CreateBusType((Bus) userInput,new Scanner(System.in).nextInt(),new Scanner(System.in).nextFloat());
                    break;
                } catch (Exception e) {
                    System.out.println("Choice.CreateType Error");
                }
            }while(true);
            System.out.println("请输入租赁天数");
            System.out.println("应付钱数为"+((Bus) userInput).CalcRent(new Scanner(System.in).nextShort()));
        }
    }
}
